<template>
	<view>
		<u-cell-group>
			<u-cell-item title="头像" :arrow="false">
				<u-avatar slot="right-icon" :src="wxavatarUrl ||avatarUrl"></u-avatar>
			</u-cell-item>
			<u-cell-item title="用户" :value="vuex_user.userName" :arrow="false"></u-cell-item>
			<u-cell-item title="登录账号" :value="vuex_user.loginCode" :arrow="false"></u-cell-item>
			<u-cell-item title="联系电话" :value="vuex_user.mobile?vuex_user.phone:''" :arrow="false"></u-cell-item>
			<u-cell-item title="电子邮箱" :value="vuex_user.email?vuex_user.email:''" :arrow="false"></u-cell-item>
			<u-cell-item title="openid" :value="vuex_user.wxOpenid?vuex_user.wxOpenid:''" :arrow="false">
				<!-- <u-button @click="Unbinding" style="margin-left:10px ;" type="success" slot="right-icon"  size="mini">解绑</u-button> -->
				<view slot="right-icon"  @click="Unbinding" 
				style="margin-left:10px;height: 35px;width: 60px;text-align: center;line-height: 35px;background-color: #27aa03;color: #fff;border-radius: 5px;"  
				>解绑</view>
			</u-cell-item>
		</u-cell-group>
		<view style="padding: 100px 10px 10px;">
			<button class="login-btn" @click="out" type="warn">退出登录</button>
		</view>
	</view> 

</template>

<script>
	export default {
		data() {
			return {
				checked:'',
				userAvatar: '',
				// model:'',
				wxavatarUrl:''
			}
		},
		computed: {
			avatarUrl() {
				let url = this.vuex_user.avatarUrl || '/ctxPath/static/images/user1.jpg';
				url = url.replace('/ctxPath/', this.vuex_config.baseUrl + '/');
				return uni.getStorageSync('wxavatarUrl') || url + '?t=' + new Date().getTime();
			}
		},
		onLoad() {
			
			// this.$u.api.index().then(res => {
			// 	if (res.result == 'true'){
			// 		this.model = res.user;
			// 	}else if (res.result == 'login'){
			// 		uni.reLaunch({
			// 			url: '/pages/btdm/index/login/index'
			// 		});
			// 	}else{
			// 		this.$u.toast(res.message);
			// 	}
			// });
		},
		methods: {
			
			Unbinding(){
				this.$u.api.shop.cleanWxOpenid({
					userCode:this.vuex_user.userCode,
				}).then(res => {
						console.log(res,'===');
						this.out()
					});
			},
			out(){
				// uni.removeStorageSync('loaclOpenId')
				// uni.reLaunch({
				// 	url: '/pages/btdm/index/login/index'
				// });
				this.$u.api.logout().then(res => {
					this.$u.toast(res.message);
					if (res.result == 'true') {
						let self = this;
						setTimeout(() => {
							// uni.reLaunch({
							// 	url: '/pages/btdm/index/login/index'
							// });
						}, 500);
					}
				});
			}
		},


	}
</script>

<style scoped>
	.login-btn{
		border-radius:10px ;
	}
	page {
		width: 100%;
		height: 100%;
	}
</style>